import sys, os

sys.path.append(os.getcwd())

from selenium.webdriver.common.by import By

from base.base_action import BaseAction


class HomePage(BaseAction):
    # 首页

    # 1、首页按钮 id = “com.chebao:id/re_weixin”
    hoem_button = By.ID, "com.chebao:id/re_weixin"

    # 2、出借按钮
    borrow_button = By.ID, "com.chebao:id/re_contact_list"

    # 3、发现按钮
    discover_button = By.ID, "com.chebao:id/re_find"

    # 4、我的按钮
    me_button = By.ID, "com.chebao:id/re_profile"

    # 5、更多 id = 	com.chebao:id/imageView
    more_button = By.ID, "com.chebao:id/imageView"

    # 6、获取首页title id = "com.chebao:id/title"
    home_title = By.ID, "com.chebao:id/title"

    # 7、新人壕礼 id = com.chebao:id/ib_weixin1
    newboy_button = By.ID, "com.chebao:id/ib_weixin1"

    # 8、信息披露
    disclosure_button = By.ID, "com.chebao:id/re_contact_list1"

    # 9、安全保障
    guarantee_button = By.ID, "com.chebao:id/re_find1"

    # 10、推介有礼  	com.chebao:id/re_four
    referrals_button = By.ID, "	com.chebao:id/re_four"

    # 11、banner

    def __init__(self, driver):
        BaseAction.__init__(self, driver)

    def click_home_button(self):
        # 点击首页按钮
        self.act_click(self.hoem_button)

    def click_borrow_button(self):
        # 点击出借
        self.act_click(self.borrow_button)

    def click_discover_button(self):
        # 点击发现
        self.act_click(self.discover_button)

    def click_me_button(self):
        # 点击我的
        self.act_click(self.me_button)

    def get_home_title(self):
        # 获取首页title
        home_title = self.find_element(self.home_title)
        return home_title.text

    def click_more(self):
        # 点击更多
        return self.act_click(self.more_button)

    def click_newboy(self):
        # 点击新人壕礼
        self.act_click(self.newboy_button)
